<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<div style="text-align:center;">
	<table style="width:100%; border-collapse:separate; border-spacing:20px;">
		<tr>
			<td style="text-align:right;">
				<label for="user_add_userName">姓名：</label>
			</td>
			<td style="text-align:left;">
				<input id="user_add_userName">
			</td>
			<td style="text-align:right;">
				<label for="user_add_userCode">编码：</label>
			</td>
			<td style="text-align:left;">
				<input id="user_add_userCode">
			</td>
		</tr>
		<tr>
			<td style="text-align:right;">
				<label for="user_add_email">邮箱：</label>
			</td>
			<td style="text-align:left;">
				<input id="user_add_email">
			</td>
			<td style="text-align:right;">
				<label for="user_add_company">机构：</label>
			</td>
			<td style="text-align:left;">
				<input id="user_add_company">
			</td>
		</tr>
		<tr>
			<td style="text-align:right;">
				<label for="user_child1_company">子机构：</label>
			</td>
			<td style="text-align:left;">
				<input id="user_child1_company"/>
			</td>
			<td style="text-align:right;">
				<label for="user_child2_company">部门：</label>
			</td>
			<td style="text-align:left;">
				<input id="user_child2_company"/>
			</td>
		</tr>
	</table>
	<script type="text/javascript">
		$(function() {
			initUserAddTag();
		});
		
		/** 初始化添加页面的各个控件  */
		function initUserAddTag() {
			$("#user_add_userCode").textbox({});
			$("#user_add_userName").textbox({});
			$("#user_add_email").textbox({});
			$("#user_add_company").combobox({editable : false});
			$("#user_child1_company").combobox({editable : false});
			$("#user_child2_company").combobox({editable : false});
			var url = "${pageContext.request.contextPath}/system/selectCompanyByCondition";
			$("#user_add_company").combobox({
				url : url,
				queryParams : {
					"comId" : ${sessionScope.USER.comId}
				},
				valueField : "comId",
				textField : "comName",
				editable : false,
				onClick : function(record) {
					$("#user_child1_company").combobox("loadData", {});
					$("#user_child2_company").combobox("loadData", {});
					$("#user_child1_company").combobox("clear");
					$("#user_child2_company").combobox("clear");
					$.post(url,
						{"parentComId" : record.comId},
						function(data) {
							if (data && data.length > 0) {
								cascadingMenu(data, url);
							}
						},"JSON"
					);
				}
			});
		}
		
		/** 加载级联下拉菜单  */
		function cascadingMenu(data, url) {
			$("#user_child1_company").combobox({
				valueField : "comId",
				textField : "comName",
				data : data,
				editable : false,
				onClick : function(record) {
					$("#user_child2_company").combobox("loadData", {});
					$("#user_child2_company").combobox("clear");
					$.post(url,
						{"parentComId" : record.comId},
						function(data1) {
							if (data1 && data1.length > 0) {
								$("#user_child2_company").combobox({
									valueField : "comId",
									textField : "comName",
									data : data1,
									editable : false
								});
							}
						},"JSON"
					);
				}
			});
		}
	</script>
</div>